import Router from '@koa/router'

export function Get(param: string) {
    return function (
        target: any,
        propertyKey: string,
        descriptor: PropertyDescriptor
    ) {
        Promise.resolve().then(() => {
            target.ROUTER = ''
            const _router = target.prototype._ROUTER_ as Router
            _router.get(param, async (ctx) => {
                const response = await descriptor.value?.(ctx.request)
                ctx.body = response
            })
        })
    }
}
